package com.moecollege.moecollegelib.image;

import android.content.Context;
import android.net.Uri;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.imagepipeline.request.ImageRequest;
import com.moecollege.moecollegelib.widget.MoeImageView;

/**
 * Created by nieyonghui on 15-5-27.
 */
public class ImageLoader {
    public static void init(Context context){
        Fresco.initialize(context);
    }

    public static void loadImage(MoeImageView imageView,Uri uri){
        ImageRequest request = ImageRequest.fromUri(uri);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setTapToRetryEnabled(true)
                .setOldController(imageView.getController())
                .setImageRequest(request)
                .build();
        imageView.setController(controller);
    }

}
